/*
 * To change this template, choose Tools | Templates
  and open the template in the editor.
 */

import java.io.*;
import java.lang.Exception.*;

public class GetUrl extends Thread{
    public static String path ="Pages.txt";
    public static String type;
    
    public GetUrl(){

    }

    @Override
    public void run(){
    	doIt();
    }

    public static void doIt(){
        
         System.out.println("It got here");
         type = "N/A";
            
         try {
         File file = new File(path);
         FileReader reader = new FileReader(file);
         BufferedReader in = new BufferedReader(reader);
         String string;
         while((string = in.readLine()) != null) {
            if( string.startsWith("http") ){
                    ParserMain lg = new ParserMain(string,type);
                    lg.doIt();
                    try{
                        Thread.currentThread().sleep(500);}catch(Exception e){}
              }else{
                    type = string.trim();}
              //  try{
              //    Thread.sleep(5000);}catch(Exception e){}
         if ((string = in.readLine()) != null) {
            if( string.startsWith("http") ){
            	 ParserMain lg = new ParserMain(string,type);
                    lg.doIt();
                     try{
                        Thread.currentThread().sleep(500);}catch(Exception e){}
              }else{
                    type = string.trim();}
             }
         }
         in.close();
       } catch (IOException e) {
         e.printStackTrace();
       }
    }
    

}
